<template>
  <router-view v-slot="{ Component, route }">
    <!-- 路由缓存 -->
    <keep-alive>
      <component :is="Component" v-if="route?.meta?.isKeepAlive || route?.meta?.isRouterKeepAlive"
        :key="route?.meta?.isRouterKeepAlive ? route?.fullPath : route?.name" />
    </keep-alive>

    <!-- 不缓存 -->
    <component :is="Component" v-if="!route?.meta?.isKeepAlive && !route?.meta?.isRouterKeepAlive" :key="route.name" />
  </router-view>
</template>

<script setup name="App">
const {
  appContext: {
    config: { globalProperties: proxy },
  },
} = getCurrentInstance()
// onMounted(async () => {
// 	await proxy.getGoodsnum();
// 	await proxy.getLang();
// });

// 获取当前页面元素
const head = document.querySelector('head')

// 创建新的meta标签并设置相关属性
const metaTag = document.createElement('meta')
metaTag.name = 'theme-color'
metaTag.setAttribute('content', '#1764ce') // 这里的#FF0000为红色示例，根据自己需求进行调整

// 将新的meta标签添加到页面头部
head.appendChild(metaTag)

window.onbeforeunload = () => {
  sessionStorage.clear()
}
</script>
